import { Component } from 'react';
import { playVideo } from 'modules/uploadVideo/core';

import './index.less';

export default class VideoPlay extends Component {
    play = () => {
        const { src, playsinline = false } = this.props;

        playVideo(this.parent, src, playsinline);
    };

    render() {
        const { poster, width } = this.props;

        return (
            <div className="video-play" ref={c => { this.parent = c; }} style={{ backgroundImage: `url(${poster})` }} onClick={this.play}>
                {!width && <img src={`${poster}`} alt="" />}
            </div>
        );
    }
}
